package com.example.hotelapp.Activity;

import android.app.Activity;
import android.content.Context;
import android.view.View;

import com.example.hotelapp.Base.BaseActivity;
import com.example.hotelapp.Fragment.HomeFragment;
import com.example.hotelapp.Fragment.MyFragment;
import com.example.hotelapp.Fragment.OrderFragment;
import com.example.hotelapp.R;
import com.example.hotelapp.Utils.IconFontTextView;

import butterknife.BindView;
import butterknife.OnClick;

import static com.example.hotelapp.Utils.MyCommonUtils.ChangeColor;
import static com.example.hotelapp.Utils.MyCommonUtils.DefaultColor;
import static com.example.hotelapp.Utils.MyCommonUtils.IntoFragment;
import static com.example.hotelapp.Utils.MyCommonUtils.setCurPoint;
import static com.example.utils.CommonUtils.QuitShowToHome;
import static com.example.utils.CommonUtils.setSystemBarColor;


/**
 * 主页2
 */
public class MainActivity2 extends BaseActivity {


    @BindView(R.id.iv_one)
    IconFontTextView ivOne;
    @BindView(R.id.iv_two)
    IconFontTextView ivTwo;
    @BindView(R.id.iv_three)
    IconFontTextView ivThree;
    private Activity activity;
    private Context context;

    /**
     * 加载布局
     */
    @Override
    protected int setLayoutId() {
        return R.layout.activity_main;
    }


    /**
     * 初始化
     */
    @Override
    protected void init() {
        context = this;
        activity = this;
        setSystemBarColor(this, R.color.white);
        IntoFragment(new OrderFragment(), this);
        selectPoint(1);
    }


    /**
     * 点击事件
     */
    @OnClick({R.id.tab_one, R.id.tab_two, R.id.tab_three})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tab_one:
                IntoFragment(new HomeFragment(), this);
                selectPoint(0);
                break;
            case R.id.tab_two:
                IntoFragment(new OrderFragment(), this);
                selectPoint(1);
                break;
            case R.id.tab_three:
                IntoFragment(new MyFragment(), this);
                selectPoint(2);
                break;
        }
    }

    /**
     * 底部Tab切换
     */
    private void selectPoint(int i) {
        if (i == 0) {
            setCurPoint(activity, ivOne, ivTwo, ivThree, ChangeColor, DefaultColor, DefaultColor);
        } else if (i == 1) {
            setCurPoint(activity, ivOne, ivTwo, ivThree, DefaultColor, ChangeColor, DefaultColor);
        } else if (i == 2) {
            setCurPoint(activity, ivOne, ivTwo, ivThree, DefaultColor, DefaultColor, ChangeColor);
        }
    }


    /**
     * 再按一次退出
     */
    @Override
    public void onBackPressed() {
        QuitShowToHome(activity);
    }

}